package com.restaurant.application.indexes.reservationlist;

import com.nebutown.description.DataTypes;
import com.nebutown.description.IndexGen;
import com.nebutown.description.UnitDescription;
import com.nebutown.description.data.Contributor;
import com.nebutown.description.data.IndexUnit;
import com.nebutown.description.data.SQLColumn;
import com.restaurant.application.indexes.reservationlist.mysql.ReservationListCriteria;
import com.restaurant.application.reservation.Reservation;

/**
 * @author Administrator
 */
public class AssistReservationListDesc extends UnitDescription {
    public static void main(String[] args) {
        getUnitDescription().run("./");
        IndexGen.run(getDescription(), "src/main/java");
    }

    private static UnitDescription getUnitDescription() {
        UnitDescription desc = UnitDescription.basicUnit(AssistReservationList.class, null);
        desc.nextBean("MiniReservationData")
                .add("id", String.class)
                .add("reservationTime", Long.class)
                .add("shopName", String.class)
        ;
        desc.addUiFunction("search", ReservationListCriteria.class.getName());
        desc.addUiFunction("modify", null);
        return desc;
    }

    public static IndexUnit getDescription() {
        return new IndexUnit()
                .withName("ReservationList")
                .withPackageName(AssistReservationListDesc.class.getPackage().getName() + ".mysql")
                .withSrcLocation("./")
                .addContributors(new Contributor()
                        .withName("reservationUid")
                        .withNullable(false)
                        .withUnique(true)
                        .withUnitType(Reservation.class.getName())
                        .addContribution(getSQLColumn("id", DataTypes.STRING, "预约id", 255))
                        .addContribution(getSQLColumn("createTime", DataTypes.LONG, "创建时间", 20))
                        .addContribution(getSQLColumn("modifyTime", DataTypes.LONG, "修改时间", 20))
                        .addContribution(getSQLColumn("number", DataTypes.STRING, "预约编号", 255))
                        .addContribution(getSQLColumn("shopUid", DataTypes.STRING, "门店Uid", 255))
                        .addContribution(getSQLColumn("shopName", DataTypes.STRING, "门店名称", 255))
                        .addContribution(getSQLColumn("serviceName", DataTypes.STRING, "服务名称", 255))
                        .addContribution(getSQLColumn("personAmount", DataTypes.STRING, "预约人数", 255))
                        .addContribution(getSQLColumn("date", DataTypes.LONG, "预约日期", 255))
                        .addContribution(getSQLColumn("time", DataTypes.STRING, "时间段", 255))
                        .addContribution(getSQLColumn("customerId", DataTypes.STRING, "客户Id", 255))
                        .addContribution(getSQLColumn("customerUid", DataTypes.STRING, "客户Uid", 255))
                        .addContribution(getSQLColumn("customerName", DataTypes.STRING, "客户名称", 255))
                        .addContribution(getSQLColumn("phone", DataTypes.STRING, "预约人联系方式", 255))
                        .addContribution(getSQLColumn("remarks", DataTypes.STRING, "备注", 255))
                        .addContribution(getSQLColumn("state", DataTypes.STRING, "状态", 255))
                );
    }

    private static SQLColumn getSQLColumn(String name, DataTypes type, String label, Integer width) {
        return new SQLColumn().withName(name).withType(type).withLabel(label).withWidth(width);
    }
}
